package com.taiyuan.tongcheng.widget;

import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.BitmapDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.PopupWindow;

import com.taiyuan.tongcheng.ui.CodeLoginActivity;
import com.taiyuan.tongcheng.ui.RegActivity;
import com.taiyuan.tongcheng.ui.ResetPwdActivity;
import com.tytc56.user.R;
/**
 * 
* @Description （登录方式选择PopupWindow）当登录遇到问题时。
* @author wzq
* @date 2015-7-30 上午11:45:51
* @update (date)
* @version V1.0
 */
public class LoginStylePopupWindow extends PopupWindow implements OnClickListener {
	private View rootView; // 总的布局
	
	//三个按钮
	private Button resetPwdBtn;
	private Button phoneCodeBtn;
	private Button cancelBtn;
	
	//两个跳转
	private Intent phoneLoginIntent;
	private Intent resetPwdIntent;
	
	//上下文
	private Context context;

	public LoginStylePopupWindow(Context context) {
		super(context);
	    this.context=context;
		this.setWidth(LayoutParams.FILL_PARENT);
		this.setHeight(LayoutParams.FILL_PARENT);
		this.setBackgroundDrawable(new BitmapDrawable());// 这样设置才能点击屏幕外dismiss窗口
		this.setOutsideTouchable(true);
		this.setAnimationStyle(R.style.timepopwindow_anim_style);
		
		LayoutInflater mLayoutInflater = LayoutInflater.from(context);
		rootView = mLayoutInflater.inflate(R.layout.layout_pw_other, null);
		resetPwdBtn=(Button)rootView.findViewById(R.id.btn_reset_pwd);
		phoneCodeBtn=(Button)rootView.findViewById(R.id.btn_code_login);
		cancelBtn=(Button)rootView.findViewById(R.id.btn_cancel);
		initIntent();
		//绑定事件
		resetPwdBtn.setOnClickListener(this);
		phoneCodeBtn.setOnClickListener(this);
		cancelBtn.setOnClickListener(this);
		setContentView(rootView);
	}

     /**
      * 
     * @Description: 初始化Intent
     * @return void
     * @throws
     * @autour wzq
     * @date 2015-7-30 下午6:47:08
     * @update (date)
      */
	private void initIntent() {
		phoneLoginIntent=new Intent(context,CodeLoginActivity.class);
		resetPwdIntent=new Intent(context,ResetPwdActivity.class);
	}


	@Override
	public void onClick(View v) 
	{
		switch (v.getId()) {
		case R.id.btn_reset_pwd:
			context.startActivity(resetPwdIntent);
			dismiss();
			break;
		case R.id.btn_code_login:
			context.startActivity(phoneLoginIntent);
			dismiss();
			break;
		case R.id.btn_cancel:
			dismiss();
			break;
		default:
			break;
		}
	}

}
